package com.ocom.webapi.service.impl;

import com.ocom.common.constant.MapKey;
import com.ocom.common.resp.Result;
import com.ocom.security.utils.SecurityUtils;
import com.ocom.webapi.feign.HumanClientService;
import com.ocom.webapi.feign.PayConfigClientService;
import com.ocom.webapi.service.AccountTypePageService;
import com.ocom.webapi.vo.accounttypepage.AddVo;
import com.ocom.webapi.vo.accounttypepage.ModifyVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Service
public class AccountTypePageServiceImpl implements AccountTypePageService {

    @Autowired
    private PayConfigClientService payConfigClientService;

    @Autowired
    private HumanClientService humanClientService;

    // 获取账号类型（AccountTypePage/onShow）
    @Override
    public Result AccountTypePageOnShow(Long comId) {
        log.info("获取账号类型请求参数:{{}}",comId);
        return payConfigClientService.GetXFAccountType(comId);
    }

    // 新增账号类型（AccountTypePage/add）
    @Override
    public Result AccountTypePageAdd(AddVo addVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(),addVo.getComId());
        map.put(mapKey.getKey_accTypeId(),addVo.getAccTypeId());
        map.put(mapKey.getKey_accTypeName(),addVo.getAccTypeName());
        map.put(mapKey.getKey_costFee(),addVo.getCostFee());
        map.put(mapKey.getKey_deposit(),addVo.getDeposit());
        map.put(mapKey.getKey_createUser(),SecurityUtils.getUsername());
        map.put(mapKey.getKey_updateUser(),SecurityUtils.getUsername());
        map.put("grouping",addVo.getGrouping());
        return payConfigClientService.AddXFAccountType(map);
    }

    // 修改账号类型（AccountTypePage/modify）
    @Override
    public Result AccountTypePageModify(ModifyVo modifyVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_accTypeId(),modifyVo.getAccTypeId());
        map.put(mapKey.getKey_comId(),modifyVo.getComId());
        map.put(mapKey.getKey_accTypeName(),modifyVo.getAccTypeName());
        map.put(mapKey.getKey_costFee(),modifyVo.getCostFee());
        map.put(mapKey.getKey_deposit(),modifyVo.getDeposit());
        map.put(mapKey.getKey_updateUser(),SecurityUtils.getUsername());
        map.put("grouping",modifyVo.getGrouping());
        return payConfigClientService.UpdateXFAccountType(map);
    }


}
